package com.example.cart.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;

import com.example.cart.entity.Product;

import java.util.Collection;
import java.util.List;

@Dao
public interface ProductDao {

    @Insert
    void insert(Product phone);

    @Insert
    void batchInsert(Collection<Product> products);

    @Delete
    int delete(Product product);

    @Delete
    int batchDelete(Collection<Product> products);

    @Query("delete from product")
    int deleteAll();

    @Query("select id, name, `desc`, price, pic_path from product  limit :limit offset :offset")
    List<Product> query(int limit, int offset);

    @Query("select id, name, `desc`, price, pic_path from product")
    List<Product> queryAll();



    @Query("select id, name, `desc`, price, pic_path from product where id in (:ids)")
    List<Product> queryByIds(Collection<String> ids);

    @Query("select id, name, `desc`, price, pic_path from product where id = :id")
    Product queryById(String id);
}
